#ifndef __STRING_H__
#define __STRING_H__

#include <assert.h>
#include "BasicType/BasicType_1.h"

namespace GCRE {
	namespace BasicType {

		class String {
			public:
				String();
				String( const String& s );
				String( const SFChar* c );
				~String();

				SFInt						Length() const;
				void							Swap( String& s );
				SFInt						find( SFChar c, SFInt pos = 0 ) const;
				SFInt						rfind( SFChar c ) const;
				String						substr( SFInt pos, SFInt n ) const;
				const SFChar*			c_str() const;
	
				operator SFUInt() const;
				SFChar						operator[]( SFInt i ) const;
				SFChar&					operator[]( SFInt i );
				String&					operator=( const String& s );
				String&					operator=( const SFChar* c );
				String&					operator+=( const SFChar* c );
				String&					operator+=( const String& s );
				String						operator+( const String& s ) const;
				String						operator+( const SFChar* c ) const;
				friend String				operator+( const SFChar* c, const String& s );

				SFBool						operator==( const String& s ) const;
				SFBool						operator==( const SFChar* c ) const;
				SFBool						operator!=( const String& s ) const;
				SFBool						operator!=( const SFChar* c ) const;
				SFBool						operator>( const String& s ) const;
				SFBool						operator>( const SFChar* c ) const;
				SFBool						operator<( const String& s ) const;
				SFBool						operator<( const SFChar* c ) const;
				SFBool						operator>=( const String& s ) const;
				SFBool						operator>=( const SFChar* c ) const;
				SFBool						operator<=( const String& s ) const;
				SFBool						operator<=( const SFChar* c ) const;

			protected:
				String( SFInt len );

			private:
				SFChar*				data;
				SFInt						length;
		};

		inline SFInt String::Length() const
		{
			return length;
		}

		inline const SFChar* String::c_str() const
		{
			return data;
		}

		inline SFChar String::operator[]( SFInt i ) const
		{
			assert( i >= 0 && i < length );
			return data[i];
		}

		inline SFChar& String::operator[]( SFInt i )
		{
			assert( i >= 0 && i < length );
			return data[i];
		}

	}
}
#endif	//	__STRING_H__